cmake_minimum_required(VERSION  3.16.3)
project(CMP)

set(CMAKE_CXX_STANDARD 20)

set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -std=c++20 -pthread")

set(SRC_DIR "${CMAKE_SOURCE_DIR}/src")
include_directories("${PROJECT_SOURCE_DIR}/include/")

# 添加额外的库文件路径
link_directories("/usr/lib/x86_64-linux-gnu/")

# 查找 src 目录下的所有 .cpp 文件
file(GLOB SRC_FILES "${SRC_DIR}/*.cpp")

# 设置可执行文件输出路径
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) 

# 创建动态库
add_library(LIBCMP SHARED ${SRC_FILES})

# 设置输出路径和动态库名
set_target_properties(LIBCMP PROPERTIES
    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" OUTPUT_NAME "cmp"
)

# 测试文件
# add_executable(th_local_test test/test_th_local.cpp)

# add_executable(boost_test test/test_boost.cpp)
# target_link_libraries(boost_test Boost::context)

# add_executable(boost_test2 test/test_boost2.cpp)
# target_link_libraries(boost_test2 Boost::context)

# add_executable(boost_test3 test/test_boost3.cpp)
# target_link_libraries(boost_test3 Boost::context)

# add_executable(proc_test test/test_proc.cpp)
# target_link_libraries(proc_test Boost::context)

add_executable(justtest test/test.cpp)
target_link_libraries(justtest LIBCMP)

add_executable(macro_test test/test_macro.cpp src/utils.cpp src/coroutine.cpp)
target_link_libraries(macro_test LIBCMP)

add_executable(coroutine_test test/test_coroutine.cpp)
target_link_libraries(coroutine_test LIBCMP)

add_executable(coroutine_test2 test/test_coroutine2.cpp)
target_link_libraries(coroutine_test2 LIBCMP)

add_executable(processor_test test/test_processor.cpp)
target_link_libraries(processor_test LIBCMP)